home *** CD-ROM | disk | FTP | other *** search
/ Hardcore Gamer Resource Kit / Hardcore Gamer Resource Kit - Disc 2.iso / Utils / UNIX / UNZIP520 / WINGUI / WIZUNZIP.C < prev    next >
C/C++ Source or Header  |  1996-04-23  |  19KB  |  490 lines

  1. /****************************************************************************
  2.  
  3.     PROGRAM: WizUnZip.c
  4.  
  5.     PURPOSE:  Windows Info-ZIP Unzip, an Unzipper for Windows
  6.     FUNCTIONS:
  7.  
  8.         WinMain() - calls initialization function, processes message loop
  9.         WizUnzipInit() - initializes window data and registers window
  10.         WizUnzipWndProc() - processes messages
  11.         About() - processes messages for "About" dialog box
  12.  
  13.     AUTHOR: Robert A. Heath,  157 Chartwell Rd. Columbia, SC 29210
  14.     I place this source module, WizUnzip.c, in the public domain.  Use it as
  15.     you will.
  16.  
  17.     Modifications: M. White - 1995, 1996
  18.       - Ported to Borland C
  19.       - Ported to WinNT and Win95
  20.       - Added dll functionality
  21. ****************************************************************************/
  22.  
  23. #define UNZIP_INTERNAL
  24. #include "unzip.h"
  25. #include <sys/types.h>
  26. #include <sys/stat.h>
  27. #include <time.h>
  28. #include <string.h>
  29. #include "wingui\wizunzip.h"
  30. #include "wizdll\wizdll.h"
  31. #ifdef WIN32
  32. #include <winver.h>
  33. #else
  34. #include <ver.h>
  35. #endif
  36.  
  37. #ifdef WIN32
  38. #define UNZ_DLL_NAME "WIZUNZ32.DLL"
  39. #else
  40. #define UNZ_DLL_NAME "WIZUNZ16.DLL"
  41. #endif
  42.  
  43. #ifndef WIZUNZIPDLL
  44. static char __based(__segname("STRINGS_TEXT")) szFirstUse[] = "FirstUse"; /* first use keyword in WIN.INI */
  45. char __based(__segname("STRINGS_TEXT")) szDefaultUnzipToDir[] = "DefaultUnzipToDir";
  46. char __based(__segname("STRINGS_TEXT")) szDefaultUnzipFromDir[] = "DefaultUnzipFromDir";
  47. char __based(__segname("STRINGS_TEXT")) szFormatKey[] = "Format";       /* Format keyword in WIN.INI        */
  48. char __based(__segname("STRINGS_TEXT")) szOverwriteKey[] = "Overwrite"; /* Overwrite keyword in WIN.INI     */
  49. char __based(__segname("STRINGS_TEXT")) szPromptOverwriteKey[] = "PromptOverwrite"; /* Prompt to Overwrite keyword in WIN.INI     */
  50. char __based(__segname("STRINGS_TEXT")) szExtractOnlyNewerKey[] = "ExtractOnlyNewer"; /* ExtractOnlyNewer keyword in WIN.INI     */
  51. char __based(__segname("STRINGS_TEXT")) szNeverOverwriteKey[] = "NeverOverwrite"; /* Overwrite keyword in WIN.INI     */
  52. char __based(__segname("STRINGS_TEXT")) szSaveUnZipToKey[] = "SaveZipToDir"; /* SaveZipToDir keyword in WIN.INI     */
  53. char __based(__segname("STRINGS_TEXT")) szSaveUnZipFromKey[] = "SaveZipFromDir"; /* SaveZipFromDir keyword in WIN.INI     */
  54. char __based(__segname("STRINGS_TEXT")) szTranslateKey[] = "Translate"; /* Translate keyword in WIN.INI     */
  55. char __based(__segname("STRINGS_TEXT")) szSpaceToUnderscoreKey[] = "SpaceToUnderscore"; /* Space to underscore keyword in WIN.INI     */
  56. char __based(__segname("STRINGS_TEXT")) szLBSelectionKey[] = "LBSelection"; /* LBSelection keyword in WIN.INI */
  57. char __based(__segname("STRINGS_TEXT")) szRecreateDirsKey[] = "Re-createDirs"; /* re-create directory structure WIN.INI keyword             */
  58. char __based(__segname("STRINGS_TEXT")) szShowBubbleHelpKey[] = "ShowBubbleHelp"; /* re-create directory structure WIN.INI keyword             */
  59. char __based(__segname("STRINGS_TEXT")) szUnzipToZipDirKey[] = "UnzipToZipDir"; /* unzip to .ZIP dir WIN.INI keyword */
  60. char __based(__segname("STRINGS_TEXT")) szHideStatus[] = "HideStatusWindow";
  61. char __based(__segname("STRINGS_TEXT")) szAutoClearStatusKey[] = "AutoClearStatus";
  62. char __based(__segname("STRINGS_TEXT")) szAutoClearDisplayKey[] = "AutoDisplayStatus";
  63. char __based(__segname("STRINGS_TEXT")) szWizUnzipIniFile[] = "WIZUNZIP.INI";
  64. char __based(__segname("STRINGS_TEXT")) szYes[] = "yes";
  65. char __based(__segname("STRINGS_TEXT")) szNo[] = "no";
  66.  
  67. /* File and Path Name variables */
  68. char __based(__segname("STRINGS_TEXT")) szAppName[] = "WizUnZip";       /* application title        */
  69. char __based(__segname("STRINGS_TEXT")) szStatusClass[] = "MsgWndw";/* status window class  */
  70.  
  71. /* Values for listbox selection WIN.INI keyword
  72.  */
  73. char * LBSelectionTable[] =
  74. {
  75. "extract", "display", "test"
  76. };
  77. #define LBSELECTIONTABLE_ENTRIES (sizeof(LBSelectionTable)/sizeof(char *))
  78. #endif /* WIZUNZIPDLL */
  79.  
  80. char __based(__segname("STRINGS_TEXT")) szHelpFileName[] = "WIZUNZIP.HLP";
  81.  
  82. HANDLE hInst;               /* current instance */
  83. HMENU  hMenu;               /* main menu handle */
  84. HANDLE hAccTable;
  85.  
  86. HANDLE hHourGlass;          /* handle to hourglass cursor        */
  87. HANDLE hSaveCursor;         /* current cursor handle         */
  88. HANDLE hHelpCursor;         /* help cursor                      */
  89. HANDLE hFixedFont;          /* handle to fixed font             */
  90. HANDLE hOldFont;            /* handle to old font               */
  91.  
  92. int hFile;                /* file handle             */
  93. HWND hWndMain;        /* the main window handle.                */
  94. HWND hWndList;            /* list box handle        */
  95. HWND hWndStatus;        /* status   (a.k.a. Messages) window */
  96. HWND hExtract;          /* extract button               */
  97. HWND hDisplay;          /*display button                */
  98. HWND hTest;             /* test button              */
  99. HWND hShowComment;      /* show comment button          */
  100. HWND hHelp;   /* help button */
  101. HWND hOpen;   /* open button */
  102. HWND hDeleteArchive; /* delete button */
  103. HWND hCopyArchive;   /* copy archive button */
  104. HWND hMoveArchive;   /* move archive button */
  105. HWND hRenameArchive; /* rename archive button */
  106. HWND hExit;
  107. HWND hMakeDir;
  108. HWND hSelectAll;
  109. HWND hDeselectAll;
  110. HWND hSelectPattern;
  111. HWND hClearStatus;
  112. HWND hCopyStatus;
  113. HWND hUnzipToDir;
  114. HWND hStatusButton;
  115. HWND hListBoxButton;
  116. HWND hSplitButton;
  117.  
  118. UF  uf;
  119.  
  120. #ifndef WIZUNZIPDLL
  121. WPARAM wLBSelection = IDM_LB_DISPLAY; /* default listbox selection action */
  122. WPARAM wWindowSelection = IDM_SPLIT; /* window selection: listbox, status, both */
  123. HBRUSH hBrush ;         /* brush for  standard window backgrounds  */
  124. LPUMB lpumb;
  125. #endif /* !WIZUNZIPDLL */
  126.  
  127. LPDCL lpDCL;
  128. HANDLE hDCL;
  129. #ifdef USEWIZUNZDLL
  130. HINSTANCE hWinDll;
  131. FARPROC DllProcessZipFiles;
  132. FARPROC GetDllVersion;
  133. #endif
  134.  
  135. HANDLE  hStrings;
  136.  
  137. int ofretval;       /* return value from initial open if filename given */
  138.  
  139. WORD cZippedFiles;      /* total personal records in file   */
  140. WORD cListBoxLines; /* max list box lines showing on screen */
  141. WORD cLinesMessageWin; /* max visible lines on message window  */
  142. WORD cchComment;            /* length of comment in .ZIP file   */
  143.  
  144. #ifndef WIZUNZIPDLL
  145. /* Forward References */
  146. int WINAPI WinMain(HANDLE, HANDLE, LPSTR, int);
  147. long WINAPI WizUnzipWndProc(HWND, WORD, WPARAM, LPARAM);
  148.  
  149. /****************************************************************************
  150.  
  151.     FUNCTION: WinMain(HANDLE, HANDLE, LPSTR, int)
  152.  
  153.     PURPOSE: calls initialization function, processes message loop
  154.  
  155.     COMMENTS:
  156.  
  157.         This will initialize the window class if it is the first time this
  158.         application is run.  It then creates the window, and processes the
  159.         message loop until a WM_QUIT message is received.  It exits the
  160.         application by returning the value passed by the PostQuitMessage.
  161.  
  162. ****************************************************************************/
  163. int WINAPI WinMain(hInstance, hPrevInstance, lpCmdLine, nCmdShow)
  164. HANDLE hInstance;         /* current instance             */
  165. HANDLE hPrevInstance;     /* previous instance            */
  166. LPSTR lpCmdLine;          /* command line                 */
  167. int nCmdShow;             /* show-window type (open/icon) */
  168. {
  169. #ifdef USEWIZUNZDLL
  170. DWORD dwVersion;  /* These variables are all used for version checking */
  171. WORD dllMajor, dllMinor;
  172. DWORD dwVerInfoSize;
  173. DWORD dwVerHnd;
  174. char szFullPath[_MAX_PATH], *ptr;
  175. #endif
  176. int i;
  177. BOOL fFirstUse;           /* first use if TRUE         */
  178.  
  179. if (!hPrevInstance)       /* Has application been initialized? */
  180.    if (!WizUnzipInit(hInstance))
  181.       return 0;           /* Exits if unable to initialize     */
  182.  
  183.  
  184. hStrings = GlobalAlloc( GPTR, (DWORD)sizeof(UMB));
  185. if ( !hStrings )
  186.    return 0;
  187.  
  188. lpumb = (LPUMB)GlobalLock( hStrings );
  189. if ( !lpumb )
  190.    {
  191.    GlobalFree( hStrings );
  192.    return 0;
  193.    }
  194. hDCL = GlobalAlloc( GPTR, (DWORD)sizeof(DCL));
  195. if (!hDCL)
  196.    {
  197.    GlobalUnlock(hStrings);
  198.    GlobalFree(hStrings);
  199.    return 0;
  200.    }
  201. lpDCL = (LPDCL)GlobalLock(hDCL);
  202. if (!lpDCL)
  203.    {
  204.    GlobalUnlock(hStrings);
  205.    GlobalFree(hStrings);
  206.    GlobalFree(hDCL);
  207.    return 0;
  208.    }
  209. #ifndef USEWIZUNZDLL
  210. CONSTRUCTGLOBALS();
  211. #endif
  212.  
  213. uf.fCanDragDrop = FALSE;
  214. #ifndef WIN32
  215. if ((hHourGlass = GetModuleHandle("SHELL"))!=0)
  216.    {
  217.    if (GetProcAddress(hHourGlass, "DragAcceptFiles" ))
  218.       uf.fCanDragDrop = TRUE;
  219.    }
  220. #else
  221. uf.fCanDragDrop = TRUE;
  222. #endif
  223.  
  224. #ifdef USEWIZUNZDLL
  225. lpDCL->print = win_fprintf;
  226. lpDCL->sound = SoundDuring;
  227. lpDCL->Stdout = stdout;
  228. lpDCL->lpUMB = lpumb;
  229.  
  230. /* Okay - we are now setting up to check the version stamp information
  231.  * in the dll. We aren't doing anything with it yet, because there is only
  232.  * one version of the dll, but this information will be useful for later
  233.  * versions. Note that we are assuming that the dll is in the same directory
  234.  * as the executable. Not a particularly valid assumption at this point, but
  235.  * it will do until we actually need this information.
  236.  */
  237. GetModuleFileName(hInstance, szFullPath, sizeof(szFullPath));
  238. ptr = strrchr(szFullPath, '\\') + 1;
  239. *ptr = '\0';      /* We've now got the path to the executable (application) */
  240. lstrcat(szFullPath, UNZ_DLL_NAME);
  241. dwVerInfoSize =
  242.     GetFileVersionInfoSize(szFullPath, &dwVerHnd);
  243.  
  244. if (dwVerInfoSize)
  245.    {
  246.    LPSTR   lpstrVffInfo; /* Pointer to block to hold info */
  247.    HANDLE  hMem;         /* handle to mem alloc'ed */
  248.  
  249.    /* Get a block big enough to hold the version information */
  250.    hMem          = GlobalAlloc(GMEM_MOVEABLE, dwVerInfoSize);
  251.    lpstrVffInfo  = GlobalLock(hMem);
  252.  
  253.    /* Get the version information */
  254.    GetFileVersionInfo(szFullPath, 0L, dwVerInfoSize, lpstrVffInfo);
  255.  
  256.    /* free memory */
  257.    GlobalUnlock(hMem);
  258.    GlobalFree(hMem);
  259.    }
  260.  
  261. hWinDll = LoadLibrary(UNZ_DLL_NAME);
  262. #ifndef WIN32
  263. if (hWinDll > HINSTANCE_ERROR)
  264. #else
  265. if (hWinDll != NULL)
  266. #endif
  267.    {
  268.    DllProcessZipFiles = GetProcAddress(hWinDll, "DllProcessZipFiles");
  269.    GetDllVersion = GetProcAddress(hWinDll, "GetDllVersion");
  270.    }
  271. else
  272.    {
  273.    char str[80];
  274.  
  275.    wsprintf (str, "Cannot find %s", UNZ_DLL_NAME);
  276.    MessageBox (hWndMain, str, szAppName, MB_ICONSTOP | MB_OK);
  277.    GlobalUnlock(hStrings);
  278.    GlobalFree(hStrings);
  279.    GlobalUnlock(hDCL);
  280.    GlobalFree(hDCL);
  281.    return 0;
  282.    }
  283.  
  284. /* If, for some reason we got a dll with the same name, we don't want to
  285.  * make a call out to never-never land. At some point we should put a message
  286.  * up saying we can't load the proper dll.
  287.  */
  288.  
  289. if (DllProcessZipFiles == NULL)
  290.    { 
  291.    FreeLibrary(hWinDll);
  292.    GlobalUnlock(hStrings);
  293.    GlobalFree(hStrings);
  294.    GlobalUnlock(hDCL);
  295.    GlobalFree(hDCL);
  296.    return 0;
  297.    }
  298. /* We need a check here in case an old beta version of the dll is out there */
  299. if (GetDllVersion != NULL)
  300.    {
  301.    (*GetDllVersion)(&dwVersion);
  302.    dllMinor = LOWORD(dwVersion);
  303.    dllMajor = HIWORD(dwVersion);
  304.    /* This is just a place holder for now, but this is where we need to
  305.     * do whatever it is we decide to do when the dll version doesn't match
  306.     */
  307.    if ((dllMajor != DLL_MAJOR) && (dllMinor != DLL_MINOR))
  308.       {
  309.       }
  310.    }
  311. #endif
  312.  
  313. #ifndef WIN32
  314. if (_fstrlen(lpCmdLine))            /* if filename passed on start-up   */
  315. #else
  316. if (strlen(lpCmdLine))            /* if filename passed on start-up   */
  317. #endif
  318.    {
  319.    if ((ofretval = OpenFile(lpCmdLine, &lpumb->of, OF_EXIST)) >= 0)
  320.       lstrcpy(lpumb->szFileName, lpumb->of.szPathName); /* save file name */
  321.  
  322.    }
  323.  
  324. /* If first time using WizUnzip 3.0, migrate any of earlier WizUnZip options from WIN.INI
  325.    to WIZUNZIP.INI.
  326. */
  327. GetPrivateProfileString(szAppName, szFirstUse, szYes, lpumb->szBuffer, 256, szWizUnzipIniFile);
  328. if ((fFirstUse = !lstrcmpi(lpumb->szBuffer, szYes))!=0) /* first time used as WizUnZip 3.0   */
  329.    {
  330. #ifndef WIZZIP
  331.    GetProfileString(szAppName, szRecreateDirsKey, szYes, lpumb->szBuffer, OPTIONS_BUFFER_LEN);
  332.    WritePrivateProfileString(szAppName, szRecreateDirsKey, lpumb->szBuffer, szWizUnzipIniFile);
  333.  
  334. /* Don't propagate translate option. Its meaning has changed. Use default: No   */
  335.  
  336.    GetProfileString(szAppName, szOverwriteKey, szNo, lpumb->szBuffer, OPTIONS_BUFFER_LEN);
  337.    WritePrivateProfileString(szAppName, szOverwriteKey, lpumb->szBuffer, szWizUnzipIniFile);
  338.  
  339.    GetProfileString(szAppName, szFormatKey, "long", lpumb->szBuffer, OPTIONS_BUFFER_LEN);
  340.    WritePrivateProfileString(szAppName, szFormatKey, lpumb->szBuffer, szWizUnzipIniFile);
  341.  
  342.    GetProfileString(szAppName, szUnzipToZipDirKey, szNo, lpumb->szBuffer, OPTIONS_BUFFER_LEN);
  343.    WritePrivateProfileString(szAppName, szUnzipToZipDirKey, lpumb->szBuffer, szWizUnzipIniFile);
  344.  
  345.    GetProfileString(szAppName, szLBSelectionKey, "display", lpumb->szBuffer, OPTIONS_BUFFER_LEN);
  346.    WritePrivateProfileString(szAppName, szLBSelectionKey, lpumb->szBuffer, szWizUnzipIniFile);
  347.  
  348.    MigrateSoundOptions();   /* Translate former beep option to new sound option   */
  349.  
  350.    WriteProfileString(szAppName, NULL, NULL); /* delete [wizunzip] section of WIN.INI file */
  351. #endif /* !WizZip */
  352. /* Flag that this is no longer the first time.                              */
  353.    WritePrivateProfileString(szAppName, szFirstUse, szNo, szWizUnzipIniFile);
  354. /* After first use, all options come out of WIZUNZIP.INI file                  */
  355.    }
  356.  
  357. /* Get initial Re-create dirs flag */
  358. GetPrivateProfileString(szAppName, szRecreateDirsKey, szYes, lpumb->szBuffer, OPTIONS_BUFFER_LEN, szWizUnzipIniFile);
  359. uf.fRecreateDirs = (BOOL)(!lstrcmpi(lpumb->szBuffer, szYes));
  360.  
  361. /* Get show toolbar help flag */
  362. GetPrivateProfileString(szAppName, szShowBubbleHelpKey, szYes, lpumb->szBuffer, OPTIONS_BUFFER_LEN, szWizUnzipIniFile);
  363. uf.fShowBubbleHelp = (BOOL)(!lstrcmpi(lpumb->szBuffer, szYes));
  364.  
  365. /* Get translate flag */
  366. GetPrivateProfileString(szAppName, szTranslateKey, szNo, lpumb->szBuffer, OPTIONS_BUFFER_LEN, szWizUnzipIniFile);
  367. uf.fTranslate = (BOOL)(!lstrcmpi(lpumb->szBuffer, szYes));
  368.  
  369. /* Get initial display format: short or long */
  370. GetPrivateProfileString(szAppName, szFormatKey, "long", lpumb->szBuffer, OPTIONS_BUFFER_LEN, szWizUnzipIniFile);
  371. uf.fFormatLong = (WORD)(!lstrcmpi(lpumb->szBuffer, "long") ? 1 : 0);
  372.  
  373. /* Get overwrite option */
  374. GetPrivateProfileString(szAppName, szOverwriteKey, szNo, lpumb->szBuffer, OPTIONS_BUFFER_LEN, szWizUnzipIniFile);
  375. lpDCL->Overwrite = (BOOL)(!lstrcmpi(lpumb->szBuffer, szYes));
  376.  
  377. /* Get prompt to overwrite option */
  378. GetPrivateProfileString(szAppName, szPromptOverwriteKey, szNo, lpumb->szBuffer, OPTIONS_BUFFER_LEN, szWizUnzipIniFile);
  379. lpDCL->PromptToOverwrite = (BOOL)(!lstrcmpi(lpumb->szBuffer, szYes));
  380.  
  381. /* Get always save zip-to dir option */
  382. GetPrivateProfileString(szAppName, szSaveUnZipToKey, szNo, lpumb->szBuffer, OPTIONS_BUFFER_LEN, szWizUnzipIniFile);
  383. uf.fSaveUnZipToDir = (BOOL)(!lstrcmpi(lpumb->szBuffer, szYes));
  384.  
  385. /* Get always save zip-from dir option */
  386. GetPrivateProfileString(szAppName, szSaveUnZipFromKey, szNo, lpumb->szBuffer, OPTIONS_BUFFER_LEN, szWizUnzipIniFile);
  387. uf.fSaveUnZipFromDir = (BOOL)(!lstrcmpi(lpumb->szBuffer, szYes));
  388.  
  389. /* Get Unzip to .ZIP dir option: yes or no  */
  390. GetPrivateProfileString(szAppName, szUnzipToZipDirKey, szNo, lpumb->szBuffer, OPTIONS_BUFFER_LEN, szWizUnzipIniFile);
  391. uf.fUnzipToZipDir = (BOOL)(!lstrcmpi(lpumb->szBuffer, szYes));
  392.  
  393. /* Get default "unzip-to" directory */
  394. GetPrivateProfileString(szAppName, szDefaultUnzipToDir, "", lpumb->szUnzipToDirName, WIZUNZIP_MAX_PATH, szWizUnzipIniFile);
  395.  
  396. /* Get Automatically Clear Status Window option */
  397. GetPrivateProfileString(szAppName, szAutoClearStatusKey, szNo, lpumb->szBuffer, OPTIONS_BUFFER_LEN, szWizUnzipIniFile);
  398. uf.fAutoClearStatus = (BOOL)(!lstrcmpi(lpumb->szBuffer, szYes));
  399.  
  400. /* Get Automatically Clear Display Window option */
  401. GetPrivateProfileString(szAppName, szAutoClearDisplayKey, szNo, lpumb->szBuffer, OPTIONS_BUFFER_LEN, szWizUnzipIniFile);
  402. uf.fAutoClearDisplay = (BOOL)(!lstrcmpi(lpumb->szBuffer, szYes));
  403.  
  404. /* Get default "unzip-from" directory */
  405. GetPrivateProfileString(szAppName, szDefaultUnzipFromDir, "", lpumb->szUnzipFromDirName, WIZUNZIP_MAX_PATH, szWizUnzipIniFile);
  406.  
  407. /* Get default listbox selection operation */
  408. GetPrivateProfileString(szAppName, szLBSelectionKey, "display", lpumb->szBuffer, OPTIONS_BUFFER_LEN, szWizUnzipIniFile);
  409.  
  410. for (i = 0; i < LBSELECTIONTABLE_ENTRIES &&
  411.    lstrcmpi(LBSelectionTable[i], lpumb->szBuffer) ; i++);
  412. InitSoundOptions();               /* initialize sound options         */
  413. wLBSelection = IDM_LB_DISPLAY;      /* assume default is to display     */
  414. if (i < LBSELECTIONTABLE_ENTRIES)
  415.    wLBSelection = (WORD) (IDM_LB_EXTRACT + i);
  416.  
  417. hWndMain = CreateWindow(szAppName,  /* window class     */
  418.         szAppName,                      /* window name      */
  419.         WS_OVERLAPPEDWINDOW,            /* window style     */
  420.         0,                              /* x position       */
  421.         0,                              /* y position       */
  422.         CW_USEDEFAULT,                  /* width            */
  423.         0,                              /* height           */
  424.         (HWND)0,                        /* parent handle    */
  425.         (HWND)0,                        /* menu or child ID */
  426.         hInstance,                      /* instance         */
  427.         NULL);                          /* additional info  */
  428.  
  429. if ( !hWndMain )
  430.    return 0;
  431.  
  432. CreateButtonBar(hWndMain);
  433. #ifdef USEWIZUNZDLL
  434. lpDCL->hWndMain = hWndMain;
  435. lpDCL->hWndList = hWndList;
  436. lpDCL->hInst = hInst;
  437. #endif
  438.  
  439. UpdateButtons(hWndMain);
  440. SizeWindow(hWndMain, TRUE);
  441. /* Enable/Disable buttons */
  442. WinAssert(hSelectAll);
  443. EnableWindow( hSelectAll, FALSE);
  444. WinAssert(hDeselectAll);
  445. EnableWindow( hDeselectAll, FALSE);
  446. WinAssert(hSelectPattern);
  447. EnableWindow( hSelectPattern, FALSE);
  448.  
  449. /* On first use, throw up About box, saying what WizUnZip is, etc. */
  450. if (fFirstUse)
  451.    {
  452.    PostMessage(hWndMain, WM_COMMAND, IDM_ABOUT, 0L);
  453.    }
  454. hHelpCursor = LoadCursor(hInstance, "HelpCursor");
  455.  
  456. WinAssert(hWndMain);
  457. ShowWindow(hWndMain, nCmdShow);
  458. UpdateWindow(hWndMain);
  459.  
  460. while ( GetMessage(&lpumb->msg, 0, 0, 0) )
  461.    {
  462.    if (hPatternSelectDlg == 0 || /* Pattern select dialog is non-modal */
  463.       !IsDialogMessage(hPatternSelectDlg, &lpumb->msg))
  464.       {
  465.       if ( !TranslateAccelerator(hWndMain, hAccTable, &lpumb->msg) )
  466.          {
  467.          TranslateMessage(&lpumb->msg);
  468.          DispatchMessage(&lpumb->msg);
  469.          }
  470.       }
  471.    }
  472. /* Don't turn on compiler aliasing or C7 will move */
  473. /* the following assignment after the GlobalFree() */
  474. /* which contains the memory for pumb! */
  475. i = (int)lpumb->msg.wParam;
  476.  
  477. GlobalUnlock( hStrings );
  478. GlobalFree( hStrings );
  479. GlobalUnlock(hDCL);
  480. GlobalFree(hDCL);
  481. #ifdef USEWIZUNZDLL
  482. FreeLibrary(hWinDll);
  483. #else
  484. DESTROYGLOBALS();
  485. #endif
  486. return i;
  487. }
  488. #endif /* WIZUNZIPDLL */
  489.  
  490.